﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Method.Mail
{
    internal static class CreateCode
    {
        /// <summary>
        /// 生成验证码
        /// </summary>
        /// <param name="length">长度</param>
        /// <returns></returns>
        internal static string create(int length) {
            Random ran = new Random();
            string z = "";
            for (int j = 0; j < length; j++)
            {
                int a = ran.Next(0, 26);
                string str;
                if (a % 2 == 0)
                { str = ((char)(65 + a)).ToString(); }
                else
                { str = ran.Next(0, 10).ToString(); }
                z = z + str;
            }
            return z;
        }

        internal static string create()
        {
            string[] str = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
            Random R = new Random();
            string verificationCode = "";
            for (int i = 0; i < 6; i++)
            {
                if (R.Next(1, 3) == 1)
                {
                    verificationCode = verificationCode + str[R.Next(0, 26)];
                }
                else
                {
                    verificationCode = verificationCode + R.Next(0, 10).ToString();
                }
            }
            return verificationCode;
        }
    }
}
